# coding: utf-8
# author: ZhenbPeng
#   date: 2017/10/17 14:08

# coding: utf-8
# author: ZhenbPeng
#   date: 2017/10/17 14:08
import os

env_redis_host = os.getenv("REDIS_HOST", "")
env_redis_port = os.getenv("REDIS_PORT", 0)
env_redis_pwd = os.getenv("REDIS_PWD", "")
env_thread_num = os.getenv("THREAD_NUM", 0)
env_worker_num = os.getenv("WORKER_NUM", 0)
env_proxypool_length = os.getenv("PROXYPOOL_LENGTH", 0)

DEBUG = False

REDIS_HOST = env_redis_host or "localhost"
REDIS_PORT = int(env_redis_port) or 6379
REDIS_PWD = env_redis_pwd or ''
THREAD_NUM = int(env_thread_num) or 50
WORKER_NUMS = int(env_worker_num) or 100
IP_USE_TIMES = 10000
PROXYPOOL_LENGTH = int(env_proxypool_length) or 1000


UA = [
    'Mozilla/5.0 (Linux; Android 6.0; Nexus 5 Build/MRA58N) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Mobile Safari/537.36'
    'Mozilla/5.0 (iPhone; CPU iPhone OS 9_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13B137 Safari/601.1',
    'Mozilla/5.0 (Linux; U; Android 4.4.4; en-US; XT1022 Build/KXC21.5-40) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 UCBrowser/10.7.0.636 U3/0.8.0 Mobile Safari/534.30',
    'Mozilla/5.0 (iPhone; CPU iPhone OS 10_3_3 like Mac OS X) AppleWebKit/603.3.8 (KHTML, like Gecko) Mobile/14G60 MicroMessenger/6.5.9 NetType/WIFI Language/zh_CN',
]

# 日志配置
LOGGING = {
    'version': 1,
    'disable_existing_loggers': False,
    'formatters': {
        'verbose': {
            'format': '%(asctime)s %(levelname)s %(filename)s <%(funcName)s>%(lineno)d %(message)s'
        },
        'simple': {
            'format': '%(levelname)s %(message)s'
        },
    },
    'handlers': {
        'file1': {
            'class': 'logging.handlers.RotatingFileHandler',
            'maxBytes': 1024 * 1024 * 200,  # 5 MB
            'backupCount': 3,
            'formatter': 'verbose',
            'filename': '/data/log/app/proxy.log'
        },
        'file2': {
            'class': 'logging.handlers.RotatingFileHandler',
            'maxBytes': 1024 * 1024 * 200,  # 5 MB
            'backupCount': 3,
            'formatter': 'verbose',
            'filename': '/data/log/app/worker.log'
        },
        'console': {
            'class': 'logging.StreamHandler',
            'formatter': 'verbose',
        },
    },
    'loggers': {
        'default': {
            'handlers': ['console', 'file1'],
            'formatter': 'verbose',
            'level': 'INFO',
        },
        'worker': {
            'handlers': ['console', 'file2'],
            'formatter': 'verbose',
            'level': 'INFO',
        },
    },
}